package com.sti.framework.models.User.controller;

import com.sti.framework.core.annotation.authorization.Authorization;
import com.sti.framework.core.data.IDEntity;
import com.sti.framework.core.web.BaseSearchWhere;
import com.sti.framework.core.web.Page;
import com.sti.framework.core.web.ResponseBodyEntity;
import com.sti.framework.core.web.SimplePage;
import com.sti.framework.models.User.data.Logs;
import com.sti.framework.models.User.service.LogsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.inject.Inject;
import javax.validation.Valid;

/**
 * 登陆日志、操作日志控制器
 *
 * 模块： 包括角色、权限等管理功能
 * 表　： 登陆日志、操作日志
 *
 * @author AutoApi
 */
@RestController
@RequestMapping("/Api/Logs")
@Api(tags = "日志管理", value = "用户管理")
public class LogsController {


    @Inject
    private LogsService logsService;

    /**
     * 列表
     */
    @ApiOperation(value = "日志列表")
    @ApiImplicitParam(name = "token", value = "登陆后获取的签名", paramType = "header", dataTypeClass = String.class, required = true)
    @Authorization(tag = "/List", describes = "日志列表")
    @GetMapping("/List")
    public ResponseBodyEntity<SimplePage<Logs>> List(Page page, BaseSearchWhere baseSearchWhere) {
        return ResponseBodyEntity.success(logsService.getListPage(page, baseSearchWhere));
    };

    /**
     * 详情
     */
    @ApiOperation(value = "日志详情")
    @ApiImplicitParam(name = "token", value = "登陆后获取的签名", paramType = "header", dataTypeClass = String.class, required = true)
    @Authorization(tag = "/List", describes = "日志列表")
    @GetMapping("/Info")
    public ResponseBodyEntity<Logs> Info(@Valid IDEntity id) {
        return ResponseBodyEntity.success(logsService.get(Long.valueOf(id.getId())));
    };

}
